Private Sub Command3_Click() 
Dim WhatMonth As Integer 
Dim WhatYear As Long 
Dim DayNum As Integer 
Dim i As Integer 
Dim NumOfDays 
WhatMonth = Month(Now) 
WhatYear = Year(Now) 
DayNum = 1 

Select Case WhatMonth 

Case 1, 3, 5, 7, 8, 10, 12 
NumOfDays = 31 
Case 4, 6, 9, 11 
NumOfDays = 30 
Case 2 
NumOfDays = 28 
End Select 

For i = 1 To NumOfDays 
Combo1.AddItem WhatMonth & "/" & DayNum & "/" & WhatYear 
DayNum = DayNum + 1 
Next 



End Sub



Report this post to a moderator
 
 10-02-2001 06:13 PM           IP: Logged 
 
  
 geoff_xrx
Fanatic Member

Registered: Oct 00
Location: Rochester, NY
Posts: 2414
VB Version: 6 Sp5
 IsDate checks to see if the string can be converted to a real date 

first it checks if the current month has 31 days...if so..set dys = 31 
if not...checks for 30 days... 
if not 30 days...then checks for 28 (feb) 

also could be done by checking if Month is = 1,3,5,7 etc... 
like HACK did 

so IsDate("9/25/01") will = true 
IsDate("10/40/01") = false 

ok? 

Hack - this would be more efficienct: 
instead of : 
For i = 1 To NumOfDays 
Combo1.AddItem WhatMonth & "/" & DayNum & "/" & WhatYear 
DayNum = DayNum + 1 
Next 


try: 
For i = 1 To NumOfDays 
Combo1.AddItem WhatMonth & "/" & i & "/" & WhatYear 
Next 

no need for the extra variable / work


__________________
"You've got yourself an I.D.Ten.T Error!" 
 
[b]Visual Basic 6 SP5


Report this post to a moderator
 
 10-02-2001 06:15 PM            IP: Logged 
 
  
 nightjam
Junior Member

Registered: Sep 01
Location: kingston
Posts: 16
VB Version: 6.0
 Access 
Thanks but how do you add to a combox box in access. Additem works great for VB.


__________________
We Jammin


Report this post to a moderator
 
 10-02-2001 06:16 PM           IP: Logged 
 
  
 Hack
Fanatic Member

Registered: Aug 01
Location: Eastpointe, Michigan
Posts: 739
VB Version: 6.0 Ent SP5
 Oops. Forgot about Leap Years. Throw this in under Case 2 

Private Function IsThisALeapYear(ByVal ThisYear As Integer) As Boolean 

IsThisALeapYear = (29 = Day(DateSerial(ThisYear, 2, 29))) 

Dim x As Integer 
x = IsThisALeapYear(2001) 
If x = True Then 
NumOfDays = 29 
Else 
NumOfDays=28 
End If 

End Function



Report this post to a moderator
 
 10-02-2001 06:17 PM           IP: Logged 
 
  
 jbart
Fanatic Member

Registered: Aug 00
Location: Austin, Texas
Posts: 815
VB Version: 6.0 Enterprise, SP5
 
visual basic code:--------------------------------------------------------------------------------Option Explicit

Private Sub Form_Load()
    Dim datFirstDay As Date
    Dim totDays As Integer
    Dim x As Integer
    
    datFirstDay = DateSerial(Year(Date), Month(Date), 1)
    totDays = Day(DateSerial(Year(Date), Month(Date) + 1, 0))
    
    For x = 0 To totDays - 1
        Combo1.AddItem DateAdd("d", x, datFirstDay)
    Next x
End Sub
--------------------------------------------------------------------------------


__________________
Win NT, Visual FoxPro 6.0

Last edited by jbart on 10-02-2001 at 06:30 PM

Report this post to a moderator
 
 10-02-2001 06:18 PM         IP: Logged 
 
  
 geoff_xrx
Fanatic Member

Registered: Oct 00
Location: Rochester, NY
Posts: 2414
VB Version: 6 Sp5
 good thinkin Hack...same here lol.... 


In access!?? hmm..should've said so before! LOL... 

hmm...let me try


__________________
"You've got yourself an I.D.Ten.T Error!" 
 
[b]Visual Basic 6 SP5


Report this post to a moderator
 
 10-02-2001 06:20 PM            IP: Logged 
 
  
 Hack
Fanatic Member

Registered: Aug 01
Location: Eastpointe, Michigan
Posts: 739
VB Version: 6.0 Ent SP5
 geoff_xrx: I like it. You are right. 

I just whipped that together, but I do like the way you tighten it up. 

nightjam: Access????? No clue. I've never used it for anything other than a backend DB.



Report this post to a moderator
 
 10-02-2001 06:22 PM           IP: Logged 
 
  
 geoff_xrx
Fanatic Member

Registered: Oct 00
Location: Rochester, NY
Posts: 2414
VB Version: 6 Sp5
 I cant remmebr how to do it! 

I think you can make a function and set the Control source to that function...but I cant remember. 

its been way too long 


__________________
"You've got yourself an I.D.Ten.T Error!" 
 
[b]Visual Basic 6 SP5


Report this post to a moderator
 
 10-02-2001 06:31 PM            IP: Logged 
 
  
 Gaffer
Hyperactive Member

Registered: Nov 00
Location: London, SE1
Posts: 460
VB Version: VB6 SP5
 
code:--------------------------------------------------------------------------------Private Sub Form_Load()

Dim i As Integer, j As Integer
Dim iY As Integer, iM As Integer
Dim sSource As String

iY = Year(Date)
iM = Month(Date)

If iM = 12 Then iY = iY + 1: End

i = DateSerial(iY, iM + 1, Day(Date)) - Date

For j = 1 To i
    sSource = sSource & DateSerial(iY, iM, j) & ";"
Next j

Me.Combo0.RowSourceType = "Value List"
Me.Combo0.RowSource = sSource
End Sub--------------------------------------------------------------------------------


 
 
